package com.example.gymmanagebackend.controller;

import com.example.gymmanagebackend.pojo.*;
import com.example.gymmanagebackend.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api/report")
public class ReportController {
    @Autowired
    private MembersService membersService;
    @Autowired
    private CourseReservationService courseReservationService;

    @Autowired
    private CoachReservationService coachReservationService;
    @Autowired
    private EvaluateService evaluateService;
    @Autowired
    private EquipmentService equipmentService;
    @GetMapping("/member/ageDistribution")
    public List<Members> getMemberAgeDistribution() {
        return membersService.getAgeDistribution();
    }

    @GetMapping("/member/genderDistribution")
    public List<Members> getMemberGenderDistribution() {
        return membersService.getGenderDistribution();
    }

    @GetMapping("/member/growthTrend")
    public List<Members> getMemberGrowthTrend() {
        return membersService.getMemberGrowthTrend();
    }

    @GetMapping("/course/reservationCount")
    public List<CourseReservation> getCourseReservationCount() {
        return courseReservationService.getCourseReservationCount();
    }

    @GetMapping("/course/genderDistribution")
    public List<CourseReservation> getCourseGenderDistribution() {
        return courseReservationService.getCourseGenderDistribution();
    }

    @GetMapping("/coach/reservationCount")
    public List<CoachReservation> getCoachReservationCount() {
        return coachReservationService.getCoachReservationCount();
    }

    @GetMapping("/coach/genderDistribution")
    public List<CoachReservation> getCoachGenderDistribution() {
        return coachReservationService.getCoachGenderDistribution();
    }

    @GetMapping("/equipment/quantity")
    public List<Equipment> getEquipmentQuantity() {
        return equipmentService.getEquipmentQuantity();
    }

    @GetMapping("/find/{id}")
    public Evaluate getEvaluateById(@PathVariable int id) {
        return evaluateService.getEvaluateById(id);
    }
    @GetMapping("/evaluate/submission")
    public Map<String, Object> getEvaluateSubmission(@RequestParam int page, @RequestParam int size) {
        int total = evaluateService.countEvaluate();
        List<Evaluate> data = evaluateService.getEvaluateSubmissionWithPagination(page, size);
        return Map.of(
                "content", data,
                "totalElements", total
        );
    }
    @GetMapping("/card/purchaseCount")
    public List<Members> getCardPurchaseCount() {
        return membersService.getCardPurchaseStatistics();
    }
    @GetMapping("/ratingDistribution")
    public List<Map<String, Object>> getEvaluateRatingDistribution() {
        return evaluateService.getEvaluateRatingDistribution();
    }

    @GetMapping("/topContents")
    public List<Map<String, Object>> getTopEvaluateContents() {
        return evaluateService.getTopEvaluateContents();
    }
}